﻿Public Class frmDBBackUp

    Dim BackupDestination As String

    Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
        Me.Close()
    End Sub

    Private Sub cmdBackup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdBackup.Click
        Call BackupDataBase()
    End Sub

    Private Sub cmdBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdBrowse.Click
        SaveFileDialog1.FileName = Format(Date.Today, "dd-MM-yyyy")
        SaveFileDialog1.ShowDialog()
        If SaveFileDialog1.FileName <> "" Then : BackupDestination = SaveFileDialog1.FileName
        End If
        txtFilePath.Text = BackupDestination
    End Sub


    Sub BackupDataBase()
        Dim icdata As New ICdataLogic
        If BackupDestination = "" Then
            MsgBox("Select A Destination", MsgBoxStyle.Information, "Inventory Manager")
            cmdBrowse.Focus()
            Exit Sub
        End If
        Try
            Me.Cursor = Cursors.WaitCursor
            icdata.DatabaseBackup(BackupDestination)
            MsgBox("Backup Database Successfully", MsgBoxStyle.Information, "Inventory Manager")
            txtFilePath.Clear()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Gulf Chemicals")
        End Try
        Me.Cursor = Cursors.Default
    End Sub

    Private Sub frmDBBackUp_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Me.Location = New Point(5, 90)
    End Sub
End Class